library(tidyr)
library(ggplot2)
library(zoo)
library(ggrepel)
library(dplyr)
library(scales)

## load up our data for modeling
load('data/readyToModel.RData')
figPath = '~/Dropbox/Apps/Overleaf/Python Package Download Trends/figures/'

#make unique list of packages
pklist <- unique(fullDF$package)

#make a smaple from the lsit
ranpk <- sample_n(as.data.frame(pklist), 16)

# subset for the package list
ranDF <- subset(fullDF, fullDF$package %in% ranpk$pklist)


p1 <- ggplot(ranDF, aes(x=monthOfLife, y=downloads, color=package)) +
  geom_point() + 
  geom_smooth() + 
  theme_bw()+
#  scale_y_continuous(breaks=c(1000, 10000, 100000, 1000000)) +
  theme(legend.position = 'none') +
  facet_wrap(~ package)
#  scale_y_continuous(labels = label_number())
p1


pklist.ran <- unique(vDF$package)
ranpk.ran <- sample_n(as.data.frame(pklist.ran), 16)
ranDF.ran <- subset(vDF, vDF$package %in% ranpk.ran$pklist)

p2 <- ggplot(ranDF.ran, aes(x=monthOfLife, y=downloads, color=package)) +
  geom_point() + 
  geom_smooth() + 
  theme_bw()+
#  scale_y_continuous(breaks=c(1000, 10000, 100000, 1000000)) +
  theme(legend.position = 'none') +
  facet_wrap(~ package)
#  scale_y_continuous(labels = label_number())
p2


pdf(paste0(figPath, 'ranTraj.pdf'))
p2
dev.off()
